package com.feeyo.groundservice.wifi.util

import android.view.Gravity
import android.widget.Toast
import com.blankj.utilcode.util.AppUtils
import com.feeyo.android.base.BaseApplication
import de.greenrobot.event.EventBus

/**
 *作者：70893 on 2024-11-11
 *描述：
 */
fun Any.post() {
    EventBus.getDefault().post(this)
}

/**
 * 显示toast
 */
fun Any.toast(msg: String, gravity: Int? = null, timeType: Int = Toast.LENGTH_SHORT) {
    if (AppUtils.isAppForeground())//只在前台提示
        Toast.makeText(BaseApplication.getContext(), msg, timeType).apply {
            gravity?.let { setGravity(Gravity.CENTER, 0, 0) }
        }.show()
}